﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using RegexProblems;

namespace QuickTester
{
	[TestClass]
	public class RegExProblemsTest
	{
		[TestMethod]
		public void CyberLineTest()
		{
			Assert.AreEqual(
				new CyberLine().LastCyberword("Zowie: This is a line of##cyber-poetry## !"),
				"cyberpoetry");

			Assert.AreEqual(
				new CyberLine().LastCyberword("2-b|!2-b -- ?"),
				"2b");

			Assert.AreEqual(
				new CyberLine().LastCyberword("if then{}; elseif schmelshif();"),
				"schmelshif");

			Assert.AreEqual(
				new CyberLine().LastCyberword("~y?"),
				"y");

			Assert.AreEqual(
				new CyberLine().LastCyberword("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"),
				"@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
		}

		[TestMethod]
		public void CheatCodeTest()
		{
			CollectionAssert.AreEqual(
				new CheatCodes().Matches("UUDDLRRLLRBASS",
					new string[] { "UUDDLRLRBA", "UUDUDLRLRABABSS", "DDUURLRLAB", "UUDDLRLRBASS", "UDLRRLLRBASS" }),
				new int[] { 0, 3, 4 },
				"This is the example from above.");

			CollectionAssert.AreEqual(
				new CheatCodes().Matches("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
					new string[] { "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" }),
				new int[] { 0 },
				"Watch your time!");

			CollectionAssert.AreEqual(
			    new CheatCodes().Matches("IDDQDDTSFHHALL",
			        new string[] {"FHHALL", "FHSHH", "IDBEHOLDA", "IDBEHOLDI", "IDBEHOLDL",
 "IDBEHOLDR", "IDBEHOLDS", "IDBEHOLDV", "IDCHOPPERS", "IDCLEV",
 "IDCLIP", "IDDQD", "IDDT", "IDFA", "IDKFA", "IDMYPOS", "IDMUS"}),
			    new int[] { 0, 11 },
			    "This is the example from above.");

			CollectionAssert.AreEqual(
			    new CheatCodes().Matches("AABBCCDDEEFFGGHHIIJJKKLLMMNNOOPPQQRRSSTTUUVVWWXXYY",
			        new string[] {"ABCDE", "BCDEF", "CDEFG", "DEFGH", "EFGHI",
 "FGHIJ", "GHIJK", "HIJKL", "IJKLM", "JKLMN",
 "KLMNO", "LMNOP", "MNOPQ", "NOPQR", "OPQRS",
 "PQRST", "QRSTU", "RSTUV", "STUVW", "TUVWX",
 "UVWXY", "VWXYZ", "WXYZA", "XYZAB", "YZABC",
 "ZABCD"}),
			    new int[] { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9,  10,  11,  12,  13,  14,  15,  16,  17,  18,  19,  20 },
			    "This is the example from above.");

			CollectionAssert.AreEqual(
			    new CheatCodes().Matches("LAKJDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
			        new string[] {"LAKJDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSS", "LAKJDGSJKGLSDKHFKDFHDGHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
 "LAKJDGSJKGLSDKHFKDFHDHHSDKKSJDHFHJGKDKLSLSLJKASSJ",  "AKJDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
 "LAJDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKHHSJ",  "LAKDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
 "LAKJDGSJKGLSDKHFKDFHDGHHSDKKSJDFHJGKDKLSLSLJKAHS",   "KJDGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
 "LAKJDGSJKGLSDKHFKDFHDHHSDKKSJDHFHJGKDKLLSLJKAHS",    "LAKGSJKGLSDKHFKDFHDGHHSDKKSJDHFHJGKDKLSLSLJKAHSJ",
 "LAKJDGJKGLSDKHFKDFHDGHHDKKSJDH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